/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : levelLogic
	/// </summary>
	public class LevelOrderPOD : IPOD 
    {
        public readonly static Func<LevelOrderPOD> FACTORY = () => new LevelOrderPOD();
		public static Func<LevelOrderPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public int frame;
		/// <summary>
        /// 
        /// </summary>
		public byte[] data;
		
		
		
		/*-- constructors --*/
		public LevelOrderPOD() {}
		public LevelOrderPOD(int frame, byte[] data) {
			this.frame = frame;
			this.data = data;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(frame);
            _out.Write_bytes(data);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            frame = _in.Read_int();
            if(!_in.HasRemaining()) return;
            data = _in.Read_bytes();
        }
		
		public LevelOrderPOD Clone() {
            LevelOrderPOD o = DynamicFactory();
            o.frame = frame;
            if (data != null) {
                o.data = (byte[])data.Clone();
            }
            return o;
        }
        
        public void Clear() {
            frame = default;
            data = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "LevelOrderPOD [";
			str += "frame=";
			str += frame;
			str += ", data=";
			str += data;
			str += "]";
			return str;
		}
		
	}
}